"use strict";

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.ajaxSend = exports.getAjaxConfig = undefined;

var _extends2 = require("babel-runtime/helpers/extends");

var _extends3 = _interopRequireDefault(_extends2);

var _objectWithoutProperties2 = require("babel-runtime/helpers/objectWithoutProperties");

var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var getAjaxConfig = function getAjaxConfig() {
    var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

    var method = _ref.method,
        body = _ref.body,
        config = (0, _objectWithoutProperties3.default)(_ref, ["method", "body"]);

    var type = method.toUpperCase();
    return (0, _extends3.default)({}, config, {
        type: type,
        data: body
    });
};
exports.getAjaxConfig = getAjaxConfig;
var ajaxSend = exports.ajaxSend = function ajaxSend(config, ajax) {
    return new Promise(function (resolve, reject) {
        ajax((0, _extends3.default)({}, getAjaxConfig(config), {
            success: resolve,
            error: reject
        }));
    });
};

exports.default = ajaxSend;